package com.yan.test.work.testpaging3

import android.annotation.SuppressLint
import android.app.Application

object AppGlobals {

    private lateinit var sApplication:Application

    @SuppressLint("PrivateApi")
    fun getApplication():Application{

        if(!::sApplication.isInitialized){
            kotlin.runCatching {
                sApplication = Class.forName("android.app.ActivityThread")
                    .getMethod("currentApplication")
                    .invoke(null  , *emptyArray()) as Application
            }.onFailure {
                it.printStackTrace()
            }
        }

        return sApplication!!

    }


}